import node_fetch from 'node-fetch'
import { IObj } from '../interface'

export default function testmodel(nodejs: string, message_type: string, condition: { [key: string]: string | number | boolean }, sessionid: string): Promise<IObj> {
	return new Promise((resolve) => {
		node_fetch(nodejs + '/service', {
			method: 'POST',
			headers: {
				'Connection': 'Keep-Alive',
				'Content-Type': 'application/json',
				'Cookie': `sessionid=${sessionid}`
			},
			body: JSON.stringify({
				message_type,
				condition
			})
		}).then((res) => {
			return res.json()
		}).then((json) => {
			resolve(json)
		})
	})
}
